

package com.hazelcast.internal.management.events;

import com.hazelcast.internal.json.JsonObject;
import com.hazelcast.internal.management.events.EventMetadata.EventType;
import com.hazelcast.internal.util.UuidUtil;

import static com.hazelcast.internal.management.events.EventMetadata.EventType.ADD_WAN_CONFIGURATION_IGNORED;

public final class WanAddConfigurationIgnoredEvent extends AbstractWanConfigurationEventBase {
    private final String reason;

    private WanAddConfigurationIgnoredEvent(String wanConfigName, String reason) {
        super(UuidUtil.newUnsecureUUID(), wanConfigName);
        this.reason = reason;
    }

    public static WanAddConfigurationIgnoredEvent alreadyExists(String wanConfigName) {
        return new WanAddConfigurationIgnoredEvent(wanConfigName, "A WAN replication config already exists with the given name.");
    }

    public static WanAddConfigurationIgnoredEvent enterpriseOnly(String wanConfigName) {
        return new WanAddConfigurationIgnoredEvent(wanConfigName, "Adding new WAN replication config is supported for enterprise clusters only.");
    }

    @Override
    public EventType getType() {
        return ADD_WAN_CONFIGURATION_IGNORED;
    }

    @Override
    public JsonObject toJson() {
        JsonObject json = super.toJson();
        json.add("reason", reason);
        return json;
    }
}
